//
//  ViewExtension.swift
//  xz-app
//
//  Created by chen on 2025/5/6.
//
import SwiftUI
import Combine

extension View {
    
    func onDebounceChange<V: Equatable>(
        of value: V,
        debounceFor duration: TimeInterval = 0.4,
        perform action: @escaping (V) -> Void
    ) -> some View {
        self.onChange(of: value) { newValue in
            DispatchQueue.main.asyncAfter(deadline: .now() + duration) {
                action(newValue)
            }
        }
    }
}

